package com.spoj;

import java.util.HashSet;
import java.util.Scanner;

public class CMPLS {

    public static void main(String[] args) {
        try{
            Scanner input = new Scanner(System.in);
            int number = input.nextInt();
            for(int i = 0; i < number; i++) {
                StringBuilder sb = new StringBuilder();
                int seq[][] = new int[101][101];
                int given = input.nextInt();
                int find = input.nextInt();
                input.nextLine();
                String givenString = input.nextLine();
                String[] arr = givenString.split(" ");
                for(int j = 0; j < given; j++){
                    seq[0][j] = Integer.parseInt(arr[j]);
                }
                for(int j = 1; j < given; j++){
                    for(int k = 0; k < given-j; k++){
                        seq[j][k] = seq[j-1][k+1] - seq[j-1][k];
                    }
                }   
            
                for(int j = 1; j <= find; j++){
                    seq[given-1][j] = seq[given-1][j-1];
                }
                for(int j = given-2; j >= 0; j--){
                    for(int k = given-j; k < given-j+find; k++){
                        seq[j][k] = seq[j+1][k-1] + seq[j][k-1];
                    }
                }
                for(int j = 0; j < find-1; j++){
                    sb.append(seq[0][given+j]).append(" ");
                    //System.out.print(seq[0][given+j] + " ");
                }
                sb.append(seq[0][given+find-1]);
               // System.out.print(seq[0][given+find-1]);
                System.out.println(sb.toString());
                //System.out.println();  
            }
            input.close(); 
        }catch(Exception e){
            e.printStackTrace();
            return;
        }
    }
}



